package com.zmn.plat.common.enums;

import com.zmn.common.dictionary.DictModel;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：维修难度枚举
 *
 * @author guoqiao
 * @since 2021/06/08 17:07
 */
public enum MaintainDifficultyEnum {

    /**
     * 维修难度
     */
    SMALL_REPAIR(1, "简单维修"),
    MEDIUM_REPAIR(2, "普通维修"),
    BIG_REPAIR(3, "中等维修"),
    HEAVY_REPAIR(4, "复杂维修"),
    ;

    private final Integer key;

    private final String value;

    MaintainDifficultyEnum(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static List<DictModel> getMaintainDifficultyList() {
        List<DictModel> list = new ArrayList<>();
        MaintainDifficultyEnum[] values = MaintainDifficultyEnum.values();
        for (MaintainDifficultyEnum p : values) {
            list.add(new DictModel(p.getKey(), p.getValue()));
        }
        return list;
    }

    public static MaintainDifficultyEnum getMaintainDifficultyEnum(Integer key) {
        Optional<MaintainDifficultyEnum> enumOptional = Stream.of(MaintainDifficultyEnum.values()).filter(s -> s.key.equals(key)).findFirst();
        return enumOptional.orElse(null);
    }

}
